using UnityEngine;
using QFramework;
using System.Linq;

namespace ProjectSurvivor
{
	public partial class TreasureChest : GameplayObject
	{
		void OnTriggerEnter2D(Collider2D other)
		{
			Global.tipe.Value = Random.Range(0, 5);
			if (other.GetComponent<CollectableArea>())
			{
				AudioKit.PlaySound("treasuer_chest");
				if (Random.Range(0, 2) == 0)
				{
					UIGamePlanel.OpenTreasurePanel.Trigger();
				}
				else
				{
					if (UIGamePlanel.treasureChestPanel != null)
					{
						UIGamePlanel.treasureChestPanel.Trigger();
					}
					
				}

				Global.tipe.Value = Random.Range(0, 8);
				this.DestroyGameObjGracefully();
			}

		}
        public override Collider2D collision2D => SelfCircleCollider2D;
	}
}
